package com.xzy.domain;

import lombok.Data;

import java.math.BigDecimal;

@Data
public class Book {
    private Integer id;
    /**
     * 书名
     */
    private String name;
    /**
     * 价格
     */
    private BigDecimal price;
    /**
     * 作者
     */
    private String author;
    /**
     * 销量
     */
    private Integer sales;
    /**
     * 库存
     */
    private Integer stock;

    /**
     * 默认页面
     */
    private String img_path = "static/img/default1.jpg";


    public Book(Integer id,String name, BigDecimal price, String author, int sales, int stock, String img_path) {
        this.id = id;
        this.name = name;
        this.price = price;
        this.author = author;
        this.sales = sales;
        this.stock = stock;
        //图片路径为空或为空串时保持默认
        if (!(img_path == null && "".equals(img_path)))
            this.img_path = img_path;
    }
    public Book(){}




    //图片路径为空或为空串时保持默认
    public void setImg_path(String img_path) {
        if (!(img_path == null && "".equals(img_path)))
            this.img_path = img_path;

    }
}
